package com.uzai.console.web.pyq;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.common.enums.DeviceTypeEnum;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.pyq.pyqjob.PyqJobDto;
import com.uzai.console.dto.pyq.pyqjob.PyqJobIdDto;
import com.uzai.console.dto.pyq.pyqjob.PyqJobIdListDto;
import com.uzai.console.dto.pyq.pyqjob.PyqJobQuery;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.pyq.PyqJobService;
import com.uzai.console.vo.pyq.pyqjob.PyqJobVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 朋友圈任务
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "朋友圈任务",tags = "个人微信|朋友圈|朋友圈任务")
@ApiSort(32)
@RestController
public class PyqJobController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(PyqJobController.class);

    @Autowired
    private PyqJobService pyqJobService;

    @ApiOperation(value = "发送任务分页查询", notes = "朋友圈发送任务分页查询", response = PyqJobVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/pyqJob/findPyqJobList")
    public Object findPyqJobList(@RequestBody PyqJobQuery pyqJobQuery){
        return pyqJobService.findPyqJobList(pyqJobQuery);
    }

    @ApiOperation(value = "获取单个发送任务", notes = "获取单个发送任务", response = PyqJobVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/pyqJob/findPyqJob")
    public Object findPyqJob(@RequestBody PyqJobIdDto pyqJobIdDto){
        return pyqJobService.findPyqJob(pyqJobIdDto);
    }

    @SystemLogType(model = SystemModelEnum.PyqJob, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "编辑发送任务", notes = "编辑发送任务" )
    @ApiOperationSupport(order = 2)
    @PostMapping("/pyqJob/updatePyqJob")
    public Object updatePyqJob(@RequestBody PyqJobDto pyqJobDto){
        pyqJobService.updatePyqJob(pyqJobDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.PyqJob, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除发送任务微信朋友圈", notes = "删除发送任务微信朋友圈")
    @ApiOperationSupport(order = 3)
    @PostMapping("/pyqJob/deleteWxPyq")
    public Object deleteWxPyq(@RequestBody PyqJobIdDto pyqJobIdDto){
        pyqJobService.deleteWxPyq(pyqJobIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.PyqJob, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除朋友圈任务", notes = "删除朋友圈任务")
    @ApiOperationSupport(order = 4)
    @PostMapping("/pyqJob/deletePyqJob")
    public Object deletePyqJob(@RequestBody PyqJobIdListDto pyqJobIdListDto){
        pyqJobService.deletePyqJob(pyqJobIdListDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.PyqJob, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "手动发送", notes = "手动发送")
    @ApiOperationSupport(order = 5)
    @PostMapping("/pyqJob/addPyqJob")
    public Object addPyqJob(@RequestBody PyqJobDto pyqJobDto){
        pyqJobService.addPyqJob(pyqJobDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.PyqJob, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "开始任务", notes = "开始任务")
    @ApiOperationSupport(order = 5)
    @PostMapping("/pyqJob/startPyqJob")
    public Object startPyqJob(@RequestBody PyqJobIdDto pyqJobIdDto){
        pyqJobService.startPyqJob(pyqJobIdDto);
        return true;
    }

}
